<!-- 佣金 -->
<template>
	<view class="publish-brokerageBox">
		<text class="title">佣金/人</text>
		<view class="content">
			<uni-easyinput type="number" :errorMessage="errorMessage" v-model="value" :trim="true" placeholder="请输入内容"
				@input="change" :clearable="false"></uni-easyinput>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			project: {
				type: Object,
				default: () => {}
			},

			submit: {
				type: Function,
				default: () => {}
			},
			data: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				value: '', //
				errorMessage: '', // 是否错误
			};
		},
		computed: {
			money() {
				console.log('运行几次mmmmmmmmmmmmmmmmmmmm');
				// 项目推荐价格
				let money1 = this.project.activityPrice
				// 持续时间
				let time1 = this.data.duration
				
				return this.project.activityPrice * this.data.duration
			}
		},
		watch:{
			project:{
				handler(){
					if(Object.keys(this.project).length>0){
						this.init()
					}
				},
				deep:true,
				immediate:true
			},
			
			data:{
				handler(){
					if(Object.keys(this.project).length>0){
						this.init()
					}
				},
				deep:true,
				immediate:true
			},
		},

		created() {
			this.init()

		},

		methods: {

			/**
			 * 初始化
			 */
			init() {
				if (this.money) {
					this.value = this.money
					this.$emit('submit', this.value)
				}
			},

			/**
			 * 修改输入框
			 */
			change(e) {
				if (Number(e) < this.money) {
					uni.showToast({
						duration: 3000,
						icon: 'none',
						title: '不能低于' + this.money + '元/人'
					})
					this.errorMessage = 'errorMessage'
				}else{
					this.errorMessage = ''
				}

				this.$emit('submit', Number(e))
			}
		}
	}
</script>

<style lang="less" scoped>
	.publish-brokerageBox {
		#padding(60rpx 24rpx 24rpx 24rpx);
		#flex(-, center, center);

		.title {
			margin-right: 24rpx;
		}

		.content {
			flex: 1;
		}

	}
</style>